const mysql = require('mysql2')
//创建连接池
const poll = mysql.createPool({
    host: '127.0.0.1',
    user: 'mydb',
    password: 'mydb',
    database: 'testmydb',
    waitForConnections: true,  //是否等待连接
    connectionLimit: 10, //最大连接数据 
    queueLimit: 0  //出现错误时，连接池请求连接的数量

})

//使用连接池
poll.query('SELECT * FROM bookinfo' , function (err, results, fields) {
    console.log('查询结果:', results);
});